﻿@model S4sme.Tasks.Blog.ViewModels.EditCategoryViewModel
           
@{
    ViewBag.Title = "Edit";
}

<h2>Category Form</h2>

@using (Html.BeginForm("EditCategory", "Admin")) {
    @Html.ValidationSummary("Please note the following:")
    @Html.AntiForgeryToken()

    <fieldset>
        <legend>Category</legend>

        @Html.HiddenFor(m => m.Category.Id)
        @Html.EditorFor(m => m.Category.Name)

        <div class="editor-label">
            @Html.LabelFor(m => m.Category.Parent)
        </div>
        <div class="editor-field">
            <!-- Manually creating dropdown because ASP.NET MVC won't handle selected-value correctly, IMO -->
            <!-- This would be a good item for a helper, which is beyond the scope of this sample. -->
            <select name="Category.Parent">
                <option value="0">-- Select Parent --</option>
                @foreach (var category in Model.AvailableCategories) {
                    <option value="@category.Id" @(category.Equals(Model.Category.Parent) ? "selected=\"selected\"" : "")>@category.Name</option>
                }
            </select>
            @Html.ValidationMessageFor(m => m.Category.Parent)
        </div>

        <p>
            <input type="submit" value="Save" /> 
            @Html.ActionLink("Cancel", "Categories")
        </p>
    </fieldset>
}
